<%@ page language="Java"import="java.util.*,descriptor.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<%
	RecruitersListDescriptor recruiterDes = (RecruitersListDescriptor)request.getAttribute("RecruiterDes");
	CompanySupsListDescriptor supervisorDes = (CompanySupsListDescriptor)request.getAttribute("SupervisorDes");
	CompanyDescriptor compDes = (CompanyDescriptor)request.getAttribute("compDes");
	OfferDescriptor offerDes = (OfferDescriptor)request.getAttribute("offerDes");
%>

<html>
	<jsp:include page="CareerHeader.jsp" >
		<jsp:param name="pageTitle" value="Work Placement Management System - Career Officer" />
	</jsp:include>
	<body  OnLoad="showmenu(document.getElementById('smenu5'));">
		<jsp:include page="CareerPageHeader.jsp"></jsp:include> 
		<div id="container">
			<jsp:include page="CareerMenu.jsp" ></jsp:include>
			<div id="content">
				<h3 class="posttitle">Career Officer - Update Recruiter's Details</h3>
				<div class="entry">
					<form method="post">
						<input type="hidden" name="action" value="updatedOffer">
						<input type="hidden" name="compID" value="<%= compDes.getId() %>"> 
						<fieldset>
							<legend>Company Details</legend>
							<p>Name: <input type="text" name="CompName" value="<%= compDes.getName() %>" disabled></p>
						</fieldset>
						<fieldset>
									<legend>Offer's Details</legend>
									<fieldset>
										<legend>Offer</legend>
										<input type="hidden" name="offerID" value="<%= offerDes.getId() %>"> 
										<p>Name: <input type="text" name="CompOfferName" value="<%= offerDes.getName() %>"></p>
										<p>Description: <br>
											<textarea name="CompOfferDescription" rows="5" cols="60"><%= offerDes.getDescription() %></textarea>
										</p>
										<fieldset>
											<legend>Recruiter and Supervisor</legend>
											<p> Select a Recruiter for this offer :
											<select name="recruiterID">  
												<option value="-1">Select a recruiter: </option>  
										<%
													int size1 = recruiterDes.sizeRecruitersList();
													for(int i=0; i<size1; i++)
													{
														String recruiterName = recruiterDes.getRecruiterDescriptors().get(i).getName() + " "+ recruiterDes.getRecruiterDescriptors().get(i).getFirstName();
														int recID = recruiterDes.getRecruiterDescriptors().get(i).getUserId();
														String selected = "";
														if(offerDes.getRecruiterId() == recID)
														{
															selected = "selected";
														}
										%>
												<option value="<%= recID %>" <%= selected %>><%= recruiterName %></option>
										<%			
													}
										%>
												<option value="-1">No Recruiter</option>  
											</select>
											</p>
											<p> Select a Supervisor for this offer :
											<select name="supervisorID">  
												<option value="-1">Select a supervisor: </option>  
										<%
													int size2 = supervisorDes.getCompanySupDescriptors().size();
													for(int i=0; i<size2; i++)
													{
														String supervisorName = supervisorDes.getCompanySupDescriptors().get(i).getName() + " "+ supervisorDes.getCompanySupDescriptors().get(i).getFirstName();
														int supID = supervisorDes.getCompanySupDescriptors().get(i).getUserId();
														String selected = "";
														if(offerDes.getCompanySup() == supID)
														{
															selected = "selected";
														}
										%>
												<option value="<%= supID %>" <%= selected %>><%= supervisorName %></option>
										<%			
													}
										%>
												<option value="-1">No Supervisor</option>  
											</select>
											</p>
										</fieldset>
										<fieldset>
											<legend>Expiry Date</legend>
											<p>Available from: <input type="text" id="calendar1" name="calendar1" value="<%= offerDes.getDateOfStart() %>"><button type="button" id="trigger1">Choose the date</button>
											    <script type="text/javascript">//<![CDATA[
											      Zapatec.Calendar.setup({
											        firstDay          : 1,
											        range             : [2008.01, 2999.12],
											        electric          : false,
											        inputField        : "calendar1",
											        button            : "trigger1",
											        ifFormat          : "%A, %B %d, %Y",
											        daFormat          : "%Y/%m/%d"
											      });
											    //]]></script>
											
											<br/>
											</p>
											<p>To:<input type="text" id="calendar2" name="calendar2" value="<%= offerDes.getDateOfEnd() %>"> <button type="button" id="trigger2">Choose the date</button>
											    <script type="text/javascript">//<![CDATA[
											      Zapatec.Calendar.setup({
											        firstDay          : 1,
											        range             : [2008.01, 2999.12],
											        electric          : false,
											        inputField        : "calendar2",
											        button            : "trigger2",
											        ifFormat          : "%A, %B %d, %Y",
											        daFormat          : "%Y/%m/%d"
											      });
											    //]]></script>
											<br/>
										</fieldset>
									</fieldset>
								<fieldset>
									<p><button type="submit">Update Offer</button> <button type="reset">Clear</button></p>
								</fieldset>
					</form>	
				</div>
	    	</div>
			<jsp:include page="CareerPageFooter.jsp"></jsp:include>
		</div>	
	</body>
</html>